import "package:ct_pa_majordomo/utils/request.dart";
import "package:dio/dio.dart";

class PlugApi {
  Future<Map> gatewayList(queryParameters) async {
    Response response = await request.get(
      "device/plug/list",
      queryParameters: queryParameters,
    );
    return response.data ?? {};
  }

  Future<Map> getAccessToken() async {
    Response response = await request.post(
      "device/plug/access-token",
    );
    return response.data ?? {};
  }

  Future<Map> addGateway(data) async {
    Response response = await request.post(
      "device/plug",
      data: data,
    );
    return response.data ?? {};
  }

  Future<Map> getGatewayInfo({required int plugId}) async {
    Response response = await request.get(
      "device/plug/$plugId",
    );
    return response.data ?? {};
  }

  Future<Map> removeGateway({required int plugId}) async {
    Response response = await request.delete(
      "device/plug/$plugId",
    );
    return response.data ?? {};
  }

  Future<Map> getAssociatedLockList({required int plugId}) async {
    Response response = await request.get(
      "device/plug/associated-lock-list/$plugId",
      // queryParameters: { "plugId": plugId }
    );
    return response.data ?? {};
  }
}

PlugApi plugApi = PlugApi();